home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / cfuncs.zip / CLOCK.C < prev    next >
C/C++ Source or Header  |  1992-01-17  |  2KB  |  47 lines

  1. /*-------------------------- ShowClock --------------------------------*/
  2. /*                                                                     */
  3. /* Description:  Displays the current system time on the screen        */
  4. /*               in the format 00:00:00 (a/p).m.                       */
  5. /*                                                                     */
  6. /* Input:                                                              */
  7. /*     **  GLOBAL VARIABLES IN FUNCS.H                                 */
  8. /*                                                                     */
  9. /*     ClockX - x coordinate of display                                */
  10. /*     ClockY - y coordinate of display                                */
  11. /*     ClockF - foreground color of display                            */
  12. /*     ClockB - background color of display                            */
  13. /*                                                                     */
  14. /* Uses WriteAt.                                                       */
  15. /*                                                                     */
  16. /*---------------------------------------------------------------------*/
  17.  
  18. #include <dos.h>
  19.  
  20. int ClockX = 1;
  21. int ClockY = 1;
  22. int ClockF = 14; /* YELLOW */
  23. int ClockB = 1;  /* BLACK  */
  24.  
  25.  
  26. void ShowClock(void)
  27. {
  28.   struct time mytime;
  29.  
  30.   gettime(&mytime);
  31.  
  32.   WriteAt( ClockX, ClockY, ClockF, ClockB, "%2d:%2.2d:%2.2d %s",
  33.     (mytime.ti_hour>12)?(int)(mytime.ti_hour-12):(int)mytime.ti_hour,
  34.     (int)mytime.ti_min,
  35.     (int)mytime.ti_sec,
  36.     (mytime.ti_hour>12)? "p.m.":"a.m.");
  37. }
  38.  
  39. void ShowDate(void)
  40. {
  41.   char tmp[35] = "";
  42.  
  43.   ConvertDate(&tmp, "", 2, 1 );
  44.  
  45.   WriteAt(81-strlen(tmp), 1, ClockF, ClockB, tmp);
  46. }
  47.